package com.xxgc.mybatis.dao;

import com.xxgc.mybatis.po.extend.UserEx;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

//操作money的dao层接口
public interface MoneyDao {
    //查询金额表 把金额分类，金额从大到小排序
    @Select("  SELECT `u_name` ,`m_money`,`m_type`\n" +
            "        FROM `users`,`money`\n" +
            "        WHERE `u_id` = `m_user_id`\n" +
            "        ORDER BY `m_type` ASC,`m_money` DESC")
    @Results(id="Money",value = {
        @Result(property = "name",column = "u_name"),
        @Result(property = "money",column = "m_money"),
        @Result(property = "type",column = "m_type")
    })
    List<UserEx> selectUserMoney();
    @Select(" select `u_name` ,`m_money`,`m_type`\n" +
            "        FROM `users`,`money`\n" +
            "        WHERE `u_id` = `m_user_id`\n" +
            "\n" +
            "        limit #{page},#{limit}")
    @ResultMap("Money")
    List<UserEx> selectLimit(Map<String, Object> map);
    //分页插件查询
    @Select(" select `u_name` ,`m_money`,`m_type`\n" +
            "        FROM `users`,`money`\n" +
            "        WHERE `u_id` = `m_user_id`")
    @ResultMap("Money")
    List<UserEx> selectUserMoneyPage();

}
